package com.company.structural.facade_pattern.facade;

import com.company.structural.facade_pattern.abstract_facade.AbstractEncryptFacde;
import com.company.structural.facade_pattern.subsystem.FileReader;
import com.company.structural.facade_pattern.subsystem.FileWriter;
import com.company.structural.facade_pattern.subsystem.NewCipherMachine;

/**
 * 位运算加密外观
 * @ClassName NewEncryptFacade
 * @Author tiezheng.han
 * @Date 2020/9/1 14:45
 **/
public class NewEncryptFacade extends AbstractEncryptFacde {

    private FileReader reader;

    private NewCipherMachine cipherMachine;

    private FileWriter fileWriter;

    public NewEncryptFacade() {
        reader = new FileReader();
        cipherMachine = new NewCipherMachine();
        fileWriter = new FileWriter();
    }

    @Override
    public void fileEncrypt(String fileNameSrc, String fileNameDes) {
        String plainStr = reader.read(fileNameSrc);
        String encryptSrt = cipherMachine.encrypt(plainStr);
        fileWriter.write(encryptSrt,fileNameDes);
    }
}
